From e7a8a4eb0605d0c0e0849501b6cad1da82d590ed Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 6 Apr 2020 13:48:57 -0400 Subject: [PATCH] Update migration guide Rewrite the sections about keymaps and menus, and add hints about modifiers. --- docs/reference/gtk/migrating-3to4.xml | 73 +++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 11 deletions(-) diff --git a/docs/reference/gtk/migrating-3to4.xml b/docs/reference/gtk/migrating-3to4.xml index b97b8f128b..634fcbe71d 100644 --- a/docs/reference/gtk/migrating-3to4.xml +++ b/docs/reference/gtk/migrating-3to4.xml @@ -397,8 +397,29 @@
Adapt to GdkKeymap API changes - The way to get a keymap has changed slightly. gdk_keymap_get_for_display() has - been renamed to gdk_display_get_keymap(). + GdkKeymap no longer exists as an independent object. + + + If you need access to keymap state, it is now exposed as properties + on the #GdkDevice representing the keyboard: #GdkDevice:direction, + #GdkDevice:has-bidi-layouts, #GdkDevice:caps-lock-state, + #GdkDevice:num-lock-state, #GdkDevice:scroll-lock-state and + #GdkDevice:modifier-state. + To obtain the keyboard device, you can use + gdk_seat_get_keyboard (gdk_display_get_default_seat (display)). + + + If you need access to translated keys for event handling, #GdkEvent + now includes all of the translated key state, including consumed + modifiers, group and shift level, so there should be no need to + do manually call gdk_keymap_translate_keyboard_state() (which has + been removed). + + + If you need to do forward or backward mapping between key codes + and key values, use gdk_display_map_keycode() and gdk_display_map_keyval(), + which is the replacement for gdk_keymap_get_entries_for_keycode() + and gdk_keymap_get_entries_for_keycode().
@@ -417,6 +438,38 @@ +
+ Adapt to changes in keyboard modifier handling + + GTK 3 has the idea that use of modifiers may differ between different + platforms, and has a #GdkModifierIntent api to let platforms provide + hint about how modifiers are expected to be used. It also promoted + the use of <Primary> instead of <Control> to specify + accelerators that adapt to platform conventions. + + + In GTK 4, the meaning of modifiers has been fixed, and backends are + expected to map the platform conventions to the existing modifiers. + The expected use of modifiers in GTK 4 is: + + GDK_CONTROL_MASK - Primary accelerators + GDK_ALT_MASK - Mnemonics + GDK_SHIFT_MASK - Extending selections + GDK_CONTROL_MASK - Modifying selections + GDK_CONTROL_MASK|GDK_ALT_MASK - Prevent text input + + + + Consequently, #GdkModifierIntent and related APIs have been removed, + and <Control> is preferred over <Primary> in accelerators. + + + A related change is that GTK 4 no longer supports the use of archaic + X11 'real' modifiers with the names Mod1,..., Mod5, and %GDK_MOD1_MASK + has been renamed to %GDK_ALT_MASK. + +
+
Stop using GtkEventBox @@ -808,15 +861,6 @@
-
- Stop using tabular menus - - Tabular menus were rarely used and complicated the menu code, - so they have been removed. If you need complex layout in menu-like - popups, consider using a #GtkPopover instead. - -
-
Stop using gtk_menu_set_display() @@ -943,6 +987,13 @@ can only be constructed from menu models, so the porting effort involves switching to menu models and actions. + + Tabular menus were rarely used and complicated the menu code, + so they have not been brought over to #GtkPopoverMenu. If you need + complex layout in menu-like popups, consider directly using a + #GtkPopover instead. + + Since menus are gone, GtkMenuButton also lost its ability to show menus, and needs to be used with popovers in GTK 4. -- 2.30.2